package com.coder520.user.controller;

import com.coder520.user.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

/**
 * Created by PC on 2017/7/31.
 */
/**
 * @Author jinpengshen [www.coder520.com]
 * @Date 2017/7/31 10:20
 * @Description 
 */

@Controller
@RequestMapping("user")
public class UserController {

    @RequestMapping("/home")
    public String home(){
        return "home";
    }



    @ResponseBody
    @RequestMapping("/userinfo")
    public User getUser(HttpSession session){
        User user = (User) session.getAttribute("userinfo");
        return user;
    }

    @RequestMapping("/loginOut")
    public String loginOut(HttpSession session){
        //销毁session
        session.invalidate();
        return "login";
    }
}
